<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Craftsman;
use App\Apply;

class CraftsmanController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Craftsman $model)
    {
        return view('pages.craftsman',['craftsmen'=>$model->with('user:id,nickname')->paginate(6)]);
    }

    public function update($id)
    {
        $status = Craftsman::find($id)->status == 0 ? 1 : 0 ;
        Craftsman::find($id)->update(['status' => $status]);
        return back()->withStatus(__('变更用户状态成功'));
    }

    public function apply(Apply $apply)
    {
        return view('pages.apply',['apply' => $apply->latest()->paginate(10)]);
    }
}
